using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;
public partial class Admin_TraLoiThem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {
            LoadDropDownList();
        }
    }
    private void LoadDropDownList()
    {
        tbBinhLuanCollection blCollection = tbBinhLuanBUS.GetAll();
        ddl_binhluan.DataTextField = tbBinhLuanColumns.NoiDung.ToString();
        ddl_binhluan.DataValueField = tbBinhLuanColumns.MaBL.ToString();
        ddl_binhluan.DataSource = blCollection;
        ddl_binhluan.DataBind();
        ddl_binhluan .Items .Insert (0,new ListItem ("All","0"));

        tbKhachHangCollection khCollection=tbKhachHangBUS .GetAll ();
        ddl_khachhang .DataTextField =tbKhachHangColumns .HoTen .ToString ();
        ddl_khachhang .DataValueField =tbKhachHangColumns .MaKH .ToString ();
        ddl_khachhang .DataSource =khCollection ;
        ddl_khachhang .DataBind ();
        ddl_khachhang.Items.Insert(0, new ListItem("All", "0"));
    }
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        try
        {
            tbTraLoi traloi = new tbTraLoi();
            traloi.BinhLuan = int.Parse (ddl_binhluan.SelectedValue) ;
            traloi.KhachHang = int.Parse(ddl_khachhang.SelectedValue);
            traloi.TraLoi = ftb_traloi.Text.ToString();
            traloi.NgayTraLoi = txt_ngaytraloi.Text.ToString();
            tbTraLoiBUS.Insert(traloi);
        }
        catch (Exception ex)
        {

        }
        Response.Redirect("~/Admin/TraLoiDanhSach.aspx");

    }
}
